package com.yjt.fresh.adpater;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanAfterSaleCheck;
import com.yjt.fresh.bean.BeanOrder;
import com.yjt.fresh.utils.CommonsToolsHelper;
import com.yjt.fresh.widget.ScrollLinearLayoutManager;

import java.util.List;

import butterknife.BindView;

/**
 * Created by UPC on 2018/8/16.
 */

public class AdpRvFrgAfterSaleCheck extends BaseQuickAdapter<BeanAfterSaleCheck, BaseViewHolder> {


    public AdpRvFrgAfterSaleCheck(int layoutResId, List<BeanAfterSaleCheck> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanAfterSaleCheck item) {

        TextView mTvOrderNum = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckOrderNum);

        TextView mTvHeadTime = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckHeadTime);

        ImageView mIv = helper.getView(R.id.ivAppRecycleItemFrgAfterSaleCheck);

        TextView mTvTitle = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckTitle);

        TextView mTvType = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckType);

        TextView mTvMoney = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckMoney);

        TextView mTvCount = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckCount);

        TextView mTvStatus = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckStatus);

        TextView mTvReason = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckReason);

        TextView mTvTime = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckTime);

        TextView tvReturnGoods = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckToReturnGoods);
        TextView tvDetail = helper.getView(R.id.tvAppRecycleItemFrgAfterSaleCheckDetail);

        helper.addOnClickListener(R.id.tvAppRecycleItemFrgAfterSaleCheckDetail);
        helper.addOnClickListener(R.id.tvAppRecycleItemFrgAfterSaleCheckToReturnGoods);

        mTvOrderNum.setText("售后单号: " + item.getBACK_ORDER_NO());
        Glide.with(mContext).load(item.getSKU_IMG()).into(mIv);
        mTvTitle.setText(item.getTITLE());
        mTvMoney.setText(item.getBACK_MONEY());
        mTvCount.setText(item.getBUYCOUNT());
        if ("2".equals(item.getSTATUS())){
            tvReturnGoods.setVisibility(View.VISIBLE);
        }else {
            tvReturnGoods.setVisibility(View.GONE);
        }
        switch (item.getSTATUS()) {
            case "1":
                mTvStatus.setText("审核中");
                mTvReason.setVisibility(View.GONE);
                mTvReason.setVisibility(View.GONE);
                break;
            case "2":
                mTvReason.setVisibility(View.GONE);
                mTvReason.setVisibility(View.GONE);
                mTvStatus.setText("商家同意退货");
                break;
            case "3":
                mTvStatus.setText("审核不通过");
                mTvReason.setVisibility(View.VISIBLE);
                mTvReason.setText("原因: "+item.getPROBLEM_DESCRIBE());
                break;
            case "4":
                mTvReason.setVisibility(View.GONE);
                mTvReason.setVisibility(View.GONE);
                mTvStatus.setText("退款中");
                break;
            case "5":
                mTvReason.setVisibility(View.GONE);
                mTvReason.setVisibility(View.GONE);
                mTvStatus.setText("已退款");
                break;
            case "6":
                mTvReason.setVisibility(View.GONE);
                mTvReason.setVisibility(View.GONE);
                mTvStatus.setText("已取消");
                break;
            default:
                break;
        }

        mTvTime.setText("申请时间: "+item.getCREATE_TIME());
    }
}
